
#include "Handler.h"
#include "Handler1st.h"
#include "Handler2nd.h"
#include "Handler3rd.h"
#include <vector>
#include <memory>

using namespace npResponsibilityChain;
using namespace std;


void doResponsibilityChain()
{
    vector<int> nums = {3, 10, 2, 54, 90, 33, 41, 5, 20};
    
    shared_ptr<Handler> handler1st = make_shared<Handler1st>();
    shared_ptr<Handler> handler2nd = make_shared<Handler2nd>();
    shared_ptr<Handler> handler3rd = make_shared<Handler3rd>();

    handler1st->setNextHandler(weak_ptr<Handler>(handler2nd));
    handler2nd->setNextHandler(weak_ptr<Handler>(handler3rd));

    for (auto num : nums)
    {
        handler1st->handlerRequest(num);
    }
}